<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #parent{
            width:100px;
            height: 100px;
            background: red;
        }
        .none{
            display: none;
        }
        /* .show{
            display: block;
        } */
    </style>
</head>
<body>
    <div id="parent" class="none">
    </div>
    <button id="toggle">toggle</button>
    <script>
        var toggle = document.getElementById("toggle");
        var parent = document.getElementById("parent");
        toggle.onclick = ()=>{
            // if(parent.className == "none"){
            //     parent.className = "show"
            // }
            // else{
            //     parent.className = "none"
            // }
            parent.classList.toggle("none");
            //执行toggle的class只能有一个
        }
    </script>
</body>
</html>